package com.runen.infinitemovement.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.module.LoadMoreModule;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.runen.infinitemovement.R;
import com.runen.infinitemovement.model.entity.CompanyHozomRankEntity;
import com.runen.infinitemovement.model.entity.RankDtoListEntity;
import com.runen.infinitemovement.model.entity.TinderRankByEntity;
import com.runen.infinitemovement.tool.CommonUtil;
import com.runen.infinitemovement.tool.GlideUtils;
import com.runen.infinitemovement.widget.imageview.RoundedCornersImage;

public class TeamFireRankingAdapter extends BaseQuickAdapter<RankDtoListEntity, BaseViewHolder> implements LoadMoreModule {
    private Context context;
    private int flag;

    public TeamFireRankingAdapter(Context context, int flag) {
        super(R.layout.item_team_fire_ranking);
        this.context = context;
        this.flag = flag;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, RankDtoListEntity item) {
        LinearLayout ll_bg = helper.getView(R.id.ll_bg);
        ImageView iv_ranking = helper.getView(R.id.iv_ranking);
        TextView tv_user_name = helper.getView(R.id.tv_user_name);
        TextView tv_ranking = helper.getView(R.id.tv_ranking);
        TextView tv_fire_num = helper.getView(R.id.tv_fire_num);
        ImageView iv_right = helper.getView(R.id.iv_right);
        if (item.isLowerStratum) {
            iv_right.setVisibility(View.VISIBLE);
        } else {
            iv_right.setVisibility(View.GONE);
        }
        tv_user_name.setText(item.name);
        if (flag == 1) {
            tv_fire_num.setText(String.valueOf(item.tinderCount));
        } else {
            tv_fire_num.setText(String.valueOf(item.sportNumber));
        }
        int position = helper.getAdapterPosition();
        if (position % 2 == 0) {
            ll_bg.setBackgroundColor(CommonUtil.getColor(R.color.color_FFF9F8F9));
        } else {
            ll_bg.setBackgroundColor(CommonUtil.getColor(R.color.white));
        }
        switch (position) {
            case 0:
                iv_ranking.setVisibility(View.VISIBLE);
                tv_ranking.setText("0" + (position + 1));
                tv_ranking.setTextColor(CommonUtil.getColor(R.color.white));
                GlideUtils.loadImage(context, CommonUtil.getDrawable(R.mipmap.ico_ranking1), iv_ranking);
                break;
            case 1:
                iv_ranking.setVisibility(View.VISIBLE);
                tv_ranking.setText("0" + (position + 1));
                tv_ranking.setTextColor(CommonUtil.getColor(R.color.white));
                GlideUtils.loadImage(context, CommonUtil.getDrawable(R.mipmap.ico_ranking2), iv_ranking);
                break;
            case 2:
                iv_ranking.setVisibility(View.VISIBLE);
                tv_ranking.setText("0" + (position + 1));
                tv_ranking.setTextColor(CommonUtil.getColor(R.color.white));
                GlideUtils.loadImage(context, CommonUtil.getDrawable(R.mipmap.ico_ranking3), iv_ranking);
                break;
            default:
                break;
        }
    }
}
